From time to time you may need to access a file within the current application folder. .Net provides a property that is set to the absolute path to the application executable, and a method can be used to extract the folder name.

using System.IO;
using System.Windows.Forms;

string appPath = Path.GetDirectoryName(Application.ExecutablePath);

Console Application project types will have to manually add a reference to the System.Windows.Forms assembly for the Application object to be exposed.

 

You may also like

  • No Related Post